package com.ruoyi.web.controller.situation;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.situation.domain.DySgHistory;
import com.ruoyi.situation.service.IDySgHistoryService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 大营束管历史Controller
 * 
 * @author lth
 * @date 2024-12-06
 */
@RestController
@RequestMapping("/situation/history")
public class DySgHistoryController extends BaseController
{
    @Autowired
    private IDySgHistoryService dySgHistoryService;

    /**
     * 查询大营束管历史列表
     */
    @PreAuthorize("@ss.hasPermi('situation:history:list')")
    @GetMapping("/list")
    public TableDataInfo list(DySgHistory dySgHistory)
    {
        startPage();
        List<DySgHistory> list = dySgHistoryService.selectDySgHistoryList(dySgHistory);
        return getDataTable(list);
    }

    /**
     * 导出大营束管历史列表
     */
    @PreAuthorize("@ss.hasPermi('situation:history:export')")
    @Log(title = "大营束管历史", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DySgHistory dySgHistory)
    {
        List<DySgHistory> list = dySgHistoryService.selectDySgHistoryList(dySgHistory);
        ExcelUtil<DySgHistory> util = new ExcelUtil<DySgHistory>(DySgHistory.class);
        util.exportExcel(response, list, "大营束管历史数据");
    }

    /**
     * 获取大营束管历史详细信息
     */
    @PreAuthorize("@ss.hasPermi('situation:history:query')")
    @GetMapping(value = "/{sghistoryId}")
    public AjaxResult getInfo(@PathVariable("sghistoryId") Long sghistoryId)
    {
        return success(dySgHistoryService.selectDySgHistoryBySghistoryId(sghistoryId));
    }

    /**
     * 新增大营束管历史
     */
    @PreAuthorize("@ss.hasPermi('situation:history:add')")
    @Log(title = "大营束管历史", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DySgHistory dySgHistory)
    {
        return toAjax(dySgHistoryService.insertDySgHistory(dySgHistory));
    }

    /**
     * 修改大营束管历史
     */
    @PreAuthorize("@ss.hasPermi('situation:history:edit')")
    @Log(title = "大营束管历史", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DySgHistory dySgHistory)
    {
        return toAjax(dySgHistoryService.updateDySgHistory(dySgHistory));
    }

    /**
     * 删除大营束管历史
     */
    @PreAuthorize("@ss.hasPermi('situation:history:remove')")
    @Log(title = "大营束管历史", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sghistoryIds}")
    public AjaxResult remove(@PathVariable Long[] sghistoryIds)
    {
        return toAjax(dySgHistoryService.deleteDySgHistoryBySghistoryIds(sghistoryIds));
    }
}
